﻿<div [@routerTransition] (window:resize)="onResize($event)">
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title">
                    <span>需求上报</span>
                </h3>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <tabset class="tab-container tabbable-line">
                    <tab heading="需求包管理" customClass="m-tabs__item">
                            <form class="horizontal-form" autocomplete="off">
                                <div class="m-form m-form--label-align-right">
                                    <div class="row align-items-center m--margin-bottom-10">
                                        <div class="col-xl-12">
                                            <div class="form-group m-form__group align-items-center">
                                                <div class="input-group">
                                                    <input [(ngModel)]="filterText" name="filterText" autoFocus class="form-control m-input" [placeholder]="l('SearchWithThreeDot')" type="text">
                                                    <span class="input-group-btn">
                                                        <button (click)="getRequirementPackages()" class="btn btn-primary" type="submit"><i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i></button>
                                                    </span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        <div class="row margin-bottom-10">
                            <div class="col-xl-6">
                                <p>需求包列表</p>
                            </div>
                            <div class="col-xl-6 text-right">
                                <input id="selectAll" type="checkbox" name="selectAll" [(ngModel)]="selectAll" style="width:18px;height:18px;padding: 4px;"><span style="font-size:18px">检索所有&nbsp;&nbsp;</span>
                                <button *ngIf="('Pages.StandardPartsManager.Requirement.Add' | permission)" class="btn btn-primary" (click)="createOrEditRequirementPackage()"><i class="fa fa-edit"></i>新增需求包</button>
                            </div>
                        </div>
                        <div class="row">
                            <div class="primeng-datatable-container"
                                    [busyIf]="primengTableHelper.isLoading">
                                <p-table #dataTable
                                            (onLazyLoad)="getRequirementPackages($event)"
                                            [value]="primengTableHelper.records"
                                            rows="{{primengTableHelper.defaultRecordsCountPerPage}}"
                                            [paginator]="false"
                                            [lazy]="true"
                                            [scrollable]="true"
                                            ScrollWidth="100%"
                                            [responsive]="primengTableHelper.isResponsive"
                                            [resizableColumns]="primengTableHelper.resizableColumns">
                                    <ng-template pTemplate="header">
                                        <tr>
                                            <th style="width: 130px" [hidden]="!isGrantedAny('Pages.StandardPartsManager.Requirement', 'Pages.StandardPartsManager.Requirement.Edit', 'Pages.StandardPartsManager.Requirement.Delete', 'Pages.StandardPartsManager.Requirement.Audit')">{{'Actions' | localize}}</th>
                                            <th style="width: 100px;text-align: center;">
                                                序号
                                            </th>
                                            <th style="width: 300px;text-align: center;"  pSortableColumn="displayName">
                                                包名称
                                                <p-sortIcon field="displayName"></p-sortIcon>
                                            </th>
                                            <th style="width: 100px;text-align: center;"  pSortableColumn="belongToModel">
                                                型号
                                                <p-sortIcon field="usableRange.belongToModel"></p-sortIcon>
                                            </th>
                                            <th style="width: 150px;text-align: center;"  pSortableColumn="batch">
                                                发次
                                                <p-sortIcon field="usableRange.batch"></p-sortIcon>
                                            </th>
                                            <th style="width: 100px;text-align: center;"  pSortableColumn="belongToComponent">
                                                部段
                                                <p-sortIcon field="usableRange.belongToComponent"></p-sortIcon>
                                            </th>
                                            <th style="width: 100px;text-align: center;"  pSortableColumn="quantityOfLaunch">
                                                批产数量
                                                <p-sortIcon field="usableRange.quantityOfLaunch"></p-sortIcon>
                                            </th>
                                            <th style="width: 120px;text-align: center;"  pSortableColumn="craftFileNumber">
                                                工艺文件编号
                                                <p-sortIcon field="craftFileNumber"></p-sortIcon>
                                            </th>
                                            <th style="width: 120px;text-align: center;"  pSortableColumn="firstLaunchDate">
                                                首发需求时间
                                                <p-sortIcon field="firstLaunchDate"></p-sortIcon>
                                            </th>
                                            <th style="width: 100px;text-align: center;" pSortableColumn="state">
                                                状态
                                                <p-sortIcon field="state"></p-sortIcon>
                                            </th>
                                            <th style="width: 120px;text-align: center;" pSortableColumn="startingUser">
                                                创建人
                                                <p-sortIcon field="startingUser"></p-sortIcon>
                                            </th>
                                            <th style="width: 120px;text-align: center;" pSortableColumn="creationTime">
                                                创建时间
                                                <p-sortIcon field="creationTime"></p-sortIcon>
                                            </th>
                                        </tr>
                                    </ng-template>
                                    <ng-template pTemplate="body" let-record="$implicit" let-rowIndex="rowIndex">
                                        <tr>
                                            <td style="width: 130px"
                                                [hidden]="!isGrantedAny('Pages.StandardPartsManager.Requirement', 'Pages.StandardPartsManager.Requirement.Edit', 'Pages.StandardPartsManager.Requirement.Delete', 'Pages.StandardPartsManager.Requirement.Audit')">
                                                <div class="btn-group dropdown" dropdown container="body">
                                                    <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                        <i class="fa fa-cog"></i><span class="caret"></span> {{"Actions" | localize}}
                                                    </button>
                                                    <ul class="dropdown-menu" *dropdownMenu>
                                                        <li *ngIf="'Pages.StandardPartsManager.Requirement.Edit' | permission">
                                                            <a href="javascript:;" (click)="addTab(record)">需求详细管理</a>
                                                        </li>
                                                        <li *ngIf="('Pages.StandardPartsManager.Requirement' | permission) && record.state != 0 ">
                                                            <a href="javascript:;" (click)="createOrEditRequirementPackage(record)">查 看</a>
                                                        </li>
                                                        <li *ngIf="('Pages.Administration.Users.Edit' | permission) && record.state == 0 ">
                                                            <a href="javascript:;" (click)="createOrEditRequirementPackage(record)">编 辑</a>
                                                        </li>
                                                        <li *ngIf="('Pages.StandardPartsManager.Requirement.Delete' | permission) && record.state != 2">
                                                            <a href="javascript:;" (click)="deleteRequirementPackage(record)">删 除</a>
                                                        </li>
                                                        <!--<li  *ngIf="('Pages.StandardPartsManager.Requirement.Audit' | permission) && record.state == 1">
                                                            <a href="javascript:;"  (click)="cancelApplyPackage(record)">撤 销</a>
                                                        </li>-->
                                                        <li *ngIf="('Pages.StandardPartsManager.Requirement.Audit' | permission) && record.state == 0">
                                                            <a href="javascript:;" (click)="agreePackage(record)">提 交</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </td>
                                            <td style="width: 100px;text-align: center;">
                                                <span class="ui-column-title">序号</span>
                                                {{rowIndex + 1}}
                                            </td>
                                            <td style="width: 300px;text-align: center;">
                                                <span class="ui-column-title">名称</span>
                                                {{record.displayName}}
                                            </td>
                                            <td style="width: 100px;text-align: center;">
                                                <span class="ui-column-title">型号</span>
                                                {{record.usableRange.belongToModel}}
                                            </td>
                                            <td style="width: 150px;text-align: center;">
                                                <span class="ui-column-title">发次</span>
                                                {{record.usableRange.batch}}
                                            </td>
                                            <td style="width: 100px;text-align: center;">
                                                <span class="ui-column-title">部段</span>
                                                {{record.usableRange.belongToComponent}}
                                            </td>
                                            <td style="width: 100px;text-align: center;">
                                                <span class="ui-column-title">批产数量</span>
                                                {{record.usableRange.quantityOfLaunch}}
                                            </td>
                                            <td style="width: 120px;text-align: center;">
                                                <span class="ui-column-title">使用单位</span>
                                                {{record.craftFileNumber}}
                                            </td>
                                            <td style="width: 120px;text-align: center;">
                                                <span class="ui-column-title">首发需求时间</span>
                                                {{record.firstLaunchDate | date:'yyyy-MM-dd'}}
                                            </td>
                                            <td style="width: 100px;text-align: center;">
                                                <span class="ui-column-title">状态</span>
                                                <span class="span_state background_gray" *ngIf="record.state==0">
                                                    {{getRequirementPackageStateString(record.state)}}
                                                </span>
                                                <span class="span_state background_orange" *ngIf="record.state==1">
                                                    {{getRequirementPackageStateString(record.state)}}
                                                </span>
                                                <span class="span_state background_green" *ngIf="record.state==2">
                                                    {{getRequirementPackageStateString(record.state)}}
                                                </span>
                                            </td>
                                            <td style="width: 120px;text-align: center;">
                                                <span class="ui-column-title">创建人</span>
                                                {{record.startingUser}}
                                            </td>
                                            <td style="width: 120px;text-align: center;">
                                                <span class="ui-column-title">创建时间</span>
                                                {{record.creationTime | date:'yyyy-MM-dd HH:mm:ss'}}
                                            </td>
                                        </tr>
                                    </ng-template>
                                </p-table>
                                <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                                    {{'NoData' | localize}}
                                </div>
                                <div class="primeng-paging-container">
                                    <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                                    #paginator
                                                    (onPageChange)="getRequirementPackages($event)"
                                                    [totalRecords]="primengTableHelper.totalRecordsCount"
                                                    [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
        
                                    </p-paginator>
                                    <span class="total-records-count">
                                        {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                                    </span>
                                </div>
                            </div>
                        </div>
                    </tab>
                    <tab *ngFor="let tab of tabs"  [heading]="tab.name"  [active]="tab.active" [active]="tab.active"  (deselect)="tab.active = false">
                            <requirementTabComponent #requirementTabComponent  (modalSave)="getRequirementPackages()" [requirementPackage]="tab.record" ></requirementTabComponent>
                    </tab>
                </tabset>
            </div>
        </div>
    </div>
    <createOrEditRequirementPackageModal #createOrEditRequirementPackageModal (modalSave)="getRequirementPackages()"></createOrEditRequirementPackageModal>
</div>
